from django.db import models
from django.forms import ModelForm

class Materia(models.Model):
    descricao = models.CharField(max_length=50)
    
    def __unicode__(self):
        return self.descricao
    
class MateriaForm(ModelForm):
    class Meta:
        model = Materia
		
class Prova(models.Model):
	descricao = models.CharField(max_length=20)
	data = models.DateTimeField('Data da prova')
	materia = models.ForeignKey(Materia)
	conteudo = models.TextField()
	
	def __unicode__(self):
		return '%s de %s em %s' % (self.descricao, self.materia.descricao, self.data.strftime('%d/%m/%y as %H:%M'))

class ProvaForm(ModelForm):
    class Meta:
	    model = Prova

class Trabalho(models.Model):
    descricao = models.CharField(max_length=20)
    data = models.DateTimeField('Data da prova')
    materia = models.ForeignKey(Materia)
    conteudo = models.TextField()
    grupo = models.CharField(max_length=100)
    
    def __unicode__(self):
		return '%s de %s em %s com %s' % (self.descricao, self.materia.descricao, self.data.strftime('%d/%m/%y as %H:%M'), self.grupo)
		
class TrabalhoForm(ModelForm):
    class Meta:
        model = Trabalho
